Yes. Both example programs could read the same data file.
The INPUT statement that reads one number looks like this:
INPUT #fileNumber, variable
The #fileNumber
must be for a file that has already been
opened for INPUT.
For numeric input,
variable
should be a numeric variable.
When the statement executes,
the next number in the file is read.
The number is separated from the other numbers in the
file by spaces, one comma, or the end of a line.
The number is read into variable
.
For example, say that the input file looks like this:
45 99 23, 17 -6.6
Say that the file has just been opened (as #7) so that nothing has been read in, yet. When the statement
INPUT #7, COST
is executed, the 45 from the first line is read in.
The value 45 is assigned to the variable COST
.
Say that the next statement to execute is
INPUT #7, SALE
What is read into SALE
?